12 int myFloor(int a
, int b
) {
13 if ((a
< 0) ^ (b
< 0)) { // negative
14 return -(abs(a
)/abs(b
)) - 1;
20 int mod(int a
, int b
) {
21 return (a
% b
+ b
) % b
;
24 int Kh(int x
, int y
) {
28 int Ka(int x
, int y
) {
29 return myFloor(2*H
*x
- B
*y
, 2*H
*B
);
32 int Kv(int x
, int y
) {
33 return myFloor(2*H
*x
+ B
*y
, 2*H
*B
);
36 bool isVertex(int x
, int y
) {
38 if (mod(y
, H
) != 0) return false;
40 if (q
% 2 == 0) return mod(x
, B
) == 0;
41 return mod(x
, B
) == (B
/2);
47 while (cin
>> B
>> H
>> x1
>> y1
>> x2
>> y2
) {
48 if (B
== 0 and H
== 0 and x1
== 0 and y1
== 0 and x2
== 0 and y2
== 0) break;
53 int ans
= abs(Kh(x1
, y1
) - Kh(x2
, y2
)) + abs(Ka(x1
, y1
) - Ka(x2
, y2
)) + abs(Kv(x1
, y1
) - Kv(x2
, y2
));
58 int g
= __gcd(abs(dx
), abs(dy
));
61 assert(!isVertex(x1
, y1
));
62 assert(!isVertex(x2
, y2
));
65 while (x
!= x2
or y
!= y2
) {
66 ans
-= 2 * isVertex(x
, y
);